package com.accp.demo.service.finance;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.accp.demo.mapper.finance.AdvanceMapper;
import com.accp.demo.pojo.PageBean;
import com.accp.demo.pojo.finance.Advance;

@Service
public class AdvanceService {
	@Autowired
	private AdvanceMapper advanceMapper;//主表
	
	/**
	 * 分页查询
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	public PageBean findByPage(int currentPage,int pageSize){
		Integer num=this.advanceMapper.count();
		if(num==0){
			num=1;
		}
		List<Advance> list=this.advanceMapper.findByPage((currentPage-1)*pageSize, pageSize);
		PageBean pageBean = new PageBean(pageSize, num, currentPage, list);
		return pageBean;
	}
	
	/**
	 * 新增主详表记录
	 * @param advance
	 */
	public void addAdvance(Map<String, Object> map){
		this.advanceMapper.addAdvance(map);
		this.advanceMapper.addAdvanceDetail(map);
	}
	
	/**
	 * 修改主表信息
	 * @param advance
	 */
	public void updateAdvance(Map<String,Object> map){
		this.advanceMapper.updateAdvance(map);
	}
	
	/**
	 * 逻辑删除该条数据
	 * @param advanceNo
	 * @param logicStatus
	 */
	public void deleteAdvance(Map<String,Object> map){
		this.advanceMapper.deleteAdvance(map);
		this.advanceMapper.deleteAdvanceDetail(map);
	}
	
	/**
	 * 修改审核状态
	 * @param map
	 */
	public void updatePermitter(Map<String,Object> map){
		this.advanceMapper.updatePermitter(map);//修改状态
		this.advanceMapper.updateCustom(map);//修改客户主文件
	}
}
